<template>
  <div class="z-split-select inline-flex relative items-center">
    <span class="z-split-select-label relative">
      <slot>{{label}}</slot>
    </span>
    <el-select class="z-split-select-select "
               popper-class="z-split-select-popper"
               v-bind="$attrs"
               v-on="$listeners"
               size="small">
      <el-option v-for="item in options"
                 :label="item.label"
                 :value="item.value"
                 :disabled="item.disabled"
                 :key="item.value">{{item.label}}</el-option>
    </el-select>
  </div>
</template>

<script>
export default {
  name: 'ZSplitSelect',
  props: {
    options: {
      type: Array,
      default: () => ([])
    },
    label: {
      type: String
    },
    placeholder: {
      type: String,
      default: 'Select'
    }
  }
}
</script>

<style lang="scss">
.z-split-select {
  color: #606266;
  font-size: 12px;
  border: 1px solid #dcdfe6;
  background: #fff;
  border-radius: 3px;

  &-label {
    padding: 7px 15px;
    &::before {
      content: "";
      position: absolute;
      display: block;
      width: 1px;
      top: 5px;
      bottom: 5px;
      right: 0;
      background: rgba(220, 223, 230, 0.5);
    }
  }
  &-select {
    border: 0;
    .el-input__inner {
      border: 0;
      width: 120px;
    }
  }
  &-popper {
    margin-top: 6px !important;
    .popper__arrow {
      display: none;
    }
    .el-select-dropdown__item.hover {
      background-color: #e8f7f6;
      color: #45c2b5;
    }
  }
}
</style>
